#nullable enable

using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace PHMEE.EnergyEfficiency;

public interface IAnalogTDRepository
{
    /// <summary>
    /// 查询 analog 超级表下的每一张子表中的指定时间范围内的最新一条数据，前闭后闭区间
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="startDateTime"></param>
    /// <param name="endDateTime"></param>
    /// <returns></returns>
    Task<List<Analog>> GetLatestByDateTimeCloseCloseAsync(Guid vesselId, DateTime startDateTime, DateTime endDateTime);
    
    /// <summary>
    /// 根据 tagname 查询 analog 超级表下的 startDateTime 和 endDateTime 之间的数据，不包含分组信息
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="tagName"></param>
    /// <param name="startDateTime"></param>
    /// <param name="endDateTime"></param>
    /// <returns></returns>
    Task<List<Analog>> GetAnalogSignalsByTagnameAsync(Guid vesselId, string tagName, DateTime startDateTime, DateTime endDateTime);

    /// <summary>
    /// 根据 tagname 列表查询 这些 tagName 对应 endDateTime 前（含）的数据，每个 tag 仅返回最新的一条数据，不包含分组信息
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="tagNames"></param>
    /// <param name="endDateTime"></param>
    /// <returns></returns>
    Task<List<Analog>> GetAnalogSignalsByTagnamesAsync(Guid vesselId, List<string> tagNames,
        DateTime endDateTime);
    
    /// <summary>
    /// 获取所有 tagdesc
    /// </summary>
    /// <param name="vesselId"></param>
    /// <returns></returns>
    Task<List<string>> GetAllAnalogTagdescAsync(Guid vesselId);
    
    /// <summary>
    /// 根据 tagdescription 查询 analog 超级表下的 startDateTime 和 endDateTime 之间的数据，不包含分组信息
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="tagDescs"></param>
    /// <param name="startDateTime"></param>
    /// <param name="endDateTime"></param>
    /// <returns></returns>
    Task<List<Analog>> GetAnalogSignalsByTagdescAsync(Guid vesselId, IEnumerable<string> tagDescs, DateTime startDateTime, DateTime endDateTime);
    
    /// <summary>
    /// 根据条件，查询 analog 超级表下的 startDateTime 和 endDateTime 之间的数据，不包含分组信息
    /// </summary>
    /// <param name="vesselId"></param>
    /// <param name="tagName"></param>
    /// <param name="tagDescs"></param>
    /// <param name="startDateTime"></param>
    /// <param name="endDateTime"></param>
    /// <param name="skipCount"></param>
    /// <param name="maxResultCount"></param>
    /// <returns></returns>
    Task<(int totalCount, List<Analog> analogs)> GetAnalogSignalsAsync(Guid vesselId,
        string? tagName, List<string>? tagDescs,
        DateTime startDateTime, DateTime endDateTime, int skipCount, int maxResultCount);
}